package com.hzqy.service.volte;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.volte.VolteReserveDao;
import com.hzqy.web.vo.volte.VolteReserveVo;

@Service
public class VolteServiceBeen {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private VolteReserveDao volteReserveDao;
	
	/**
	 * 查询预约信息
	 * @param volteReserveVo
	 * @return
	 */
	public Map<String, Object> selectReserve(VolteReserveVo volteReserveVo,int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		
		map.put("f_vr_phone", volteReserveVo.getF_vr_phone());
		map.put("f_vr_username", volteReserveVo.getF_vr_username());
		map.put("f_vr_status", volteReserveVo.getF_vr_status());
		map.put("beginDate", volteReserveVo.getBeginDate());
		map.put("endDate", volteReserveVo.getEndDate());
		Integer rowCount = 0;
		rowCount = volteReserveDao.selectReserveCount(map);
		map.put("total", rowCount);
		
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			
			List<VolteReserveVo> results = new ArrayList<VolteReserveVo>();
			results = volteReserveDao.selectReserveList(map);
			
			map.put("rows", results);
		}else{
			map.put("rows", new ArrayList<VolteReserveVo>());
		}
		
		return map;
	}
	
	public int updateReserve(int f_vr_id) {
		int flag = 0;
		if(f_vr_id <=0) {
			flag = -1;
		}
		if(flag == 0) {
			volteReserveDao.updateReserve(f_vr_id);
			return 1;
		}
		return flag;
	}
	
}
